package net.cyndeline.entitySystem

import scala.collection.mutable.Map

trait ComponentTable {
  
  /**
   * Returns a component that belongs to an entity.
   * @param entityId The entity that (may) contain a component of a 
   * 				 certain class.
   * @param componentClass The type of component to be retrieved-
   * @return A component of the specified class if the entity contains it,
   * 		 otherwise None.
   */
  def get[A <: Component](entityId: Int, componentClass: Class[A]): Option[Component]
  
  /**
   * Adds a component to an entity id.
   * @param entityId Entity to add component to.
   * @param component Component to add.
   * @return The component that was added.
   */
  def put(entityId: Int, component: Component): Option[Component]
  
  /**
   * Removes a component from an entity.
   * @param entityId Entity to remove component from.
   * @param componentClass Type of component to remove.
   * @return Component that was removed.
   */
  def remove[T <: Component](entityId: Int, componentClass: Class[T]): Option[T]
  
  /**
   * Removes every component for an entity. This is done by retrieving every
   * component map and remove the entity key from it.
   */
  def remove(entityId: Int): Unit
  
  /**
   * Removes every key-value pair from the table.
   */
  def clear: Unit
  
  /**
   * @param componentClass Type of component.
   * @return The total number of components of a specific class.
   */
  def getComponentCount(componentClass: Class[_ <: Component]): Int
  
  /**
   * @param entityId Entity to fetch components from.
   * @return Iterable collection of every component associated with an entity.
   */
  def iterateComponents(entityId: Int): Iterator[Component]
  
//  /**
//   * This method returned an iterator in the original framework, which isn't
//   * needed since scala has native support for that.
//   * @param componentClass Type of component to fetch iterator for.
//   * @return An iterator over all entity-component pairs.
//   */
//  def componentMappingss[T <: Component](componentClass: Class[T]): Option[Map[Int, Component]]
  
//  /**
//   * Retrieves every entity id currently in the table.
//   * @return An iterator without duplicates containing every entity id
//   * 		 currently in the table.
//   */
//  def entityIdIteratorss: Iterator[Int]
  
  /**
   * @return The total number of entities in the table.
   */
  def numEntities: Int
}